using Assets.Scripts.GDK;
using System;
using UnityEngine;
using UnityEngine.UI;

namespace Brick
{
	public class GuideAlert : gdk_base_layer
	{
		public Image infoImg;

		public RectTransform btn;

		public void OnData(int id)
		{
			infoImg.gameObject.SetActive(value: true);
			btn.gameObject.SetActive(value: false);
			setInfoImg(id);
		}

		public void OnData(int id, Action callback)
		{
			infoImg.gameObject.SetActive(value: true);
			btn.gameObject.SetActive(value: true);
			setInfoImg(id);
			btn.gameObject.GetComponent<Button>().onClick.AddListener(delegate
			{
				callback();
			});
		}

		private void setInfoImg(int id)
		{
			string path = getInfoImg(id);
			Sprite sprite = Resources.Load(path, typeof(Sprite)) as Sprite;
			Vector2 size = sprite.rect.size;
			float x = size.x;
			Vector2 size2 = sprite.rect.size;
			float y = size2.y;
			infoImg.overrideSprite = sprite;
			RectTransform component = infoImg.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(x, y);
		}

		private string getInfoImg(int id)
		{
			switch (id)
			{
				case 1:
					return "Textures/Guide/infoImg/1";
				case 2:
					return "Textures/Guide/infoImg/2";
				case 3:
					return "Textures/Guide/infoImg/3";
				case 4:
					return "Textures/Guide/infoImg/4";
				case 5:
					return "Textures/Guide/infoImg/5";
				case 6:
					return "Textures/Guide/infoImg/6";
				case 7:
					return "Textures/Guide/infoImg/7";
				case 8:
					return "Textures/Guide/infoImg/8";
				default:
					return "Textures/Guide/infoImg/9";
			}
		}

		public override void OnLoad()
		{
			base.gameObject.GetComponent<RectTransform>().localPosition = new Vector3(0f, 0f, -100f);
		}
	}
}

